Skip to content

feat(schedule): book each card's hours: runs, priority changes and downtime - #328

Merged
T-Crypt merged 1 commit into
nextfrom
T-Crypt/gpu-scheduler
Nov 14, 2026
Merged

T-Crypt merged 1 commit into
nextfrom
T-Crypt/gpu-scheduler

Conversation

@T-Crypt

@T-Crypt T-Crypt commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Each card gets a schedule, up to 14 days ahead. The queue still decides who goes next; a booking decides whose hours they are.

What a booking does

Kind Effect while it holds
run The engine's (or group's) waiter goes first in line and runs at the booking's priority, foreground by default. It wins a tie against a holder with no booking. Once it holds the card, nothing but a hold drains it. min_turn still protects the holder it takes over from.
priority The engine runs at another class for the hours, then goes back. Claims no time on the card.
down No new work starts, and holders drain at their boundary when it begins. A hold and a training stay.

Hours nobody booked run by priority, then arrival, as before. A booked engine that does not ask for the card leaves it to everyone else. Two runs or downtimes on one card may not overlap, and neither may two priority changes for the same engine. berth queue prio wins over a booking, and a booking never moves a hold or a training.

Where it shows up

  • berth schedule lists RUNNING, QUEUED and BOOKED. book, move ID and cancel ID change the schedule. --days N repeats a booking on consecutive days, all or none, and --earliest finds the first free hours.
  • GET/POST /v1/berth/schedule and PATCH/DELETE /v1/berth/schedule/{id} on the gateway. Agents book, move and cancel runs only. Priority changes and downtime stay the operator's, so PATCH or DELETE on one is a 403.
  • The harbor's SCHEDULE tab: NOW, a 7-day board of 24-hour tracks (bookings to the minute, engine windows, the live holder, a now line), and a list. A paired device books through POST /v1/board/schedule, which goes to berthd's socket and never to the gateway. The form says what the booking will do before you save it.
  • Status carries bookings, and each lease carries booking (the ID that sets its class). Events: schedule.booked and lease.booking_priority.
  • berthd keeps the bookings in schedule.json in its state directory (berth daemon --schedule, "" turns it off).

Proof

  • Broker: TestRunBookingLiftsItsWaiterAndDrainsALowerHolder, TestRunBookingWinsATie, TestRunBookingKeepsItsHolderUntilItEnds, TestRunBookingGoesFirstInLine, TestPriorityBookingMovesTheClassAndBack, TestDowntimeDrainsAndTakesNoNewWork. With inRun forced false, all of them and the CLI end-to-end test go red. With the tie rule reverted, TestRunBookingWinsATie goes red.
  • Store: persistence, clash rules, earliest, all-or-nothing days, rebook and unbook, Check refusals, ParseAt. TestBookingsReadTheNodesClock reproduces a live bug (a browser's UTC times showed as "Sun 06:00" for a 23:00 booking at UTC-7). It fails without the fix.
  • End to end over real sockets: TestScheduleAgainstADaemon (CLI), TestScheduleRoutes and TestScheduleRoutesLeaveTheOperatorsBookings (gateway), TestBoardSchedule (harbor, paired and unpaired).
  • Live, on a throwaway berthd and harbor on the real card: paired a browser and booked three nights from the dialog. A clashing downtime was refused in the dialog with berthd's reason. berth run --as sft --priority batch ran at foreground under its run booking and drained a foreground chat holder ("sft (foreground) needs the card"). The NOW panel showed BOOKED b4.
  • Full proof: build, gofmt, vet, go test ./..., the Windows build and vet, golangci-lint 2.14.0.

…wntime

berthd keeps a schedule per card, up to 14 days ahead, in schedule.json.
A run booking is an engine's turn: its waiter goes first, runs at the
booking's priority, wins a tie against an unbooked holder, and keeps the
card against everything but a hold until the booking ends. A priority
booking moves an engine to another class for set hours. Downtime takes
no new work and drains holders at the start; holds and trainings stay.
Hours nobody booked run by priority, then arrival, as before.

berth schedule shows what holds each card, the queue and the bookings,
and books, moves and cancels them. The gateway's /v1/berth/schedule lets
agents read the scheduler and book their own runs. The harbor gains a
SCHEDULE tab with a 7-day board of 24-hour tracks, and a paired device
books from it through berthd's socket.
@T-Crypt
T-Crypt merged commit 5730483 into next Nov 14, 2026
4 checks passed
@T-Crypt
T-Crypt deleted the T-Crypt/gpu-scheduler branch November 14, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant